fn main() {
    let s = String::new();
    println!("{s}");

    let data = "string url";
    let s = data.to_string();
    println!("{s}");

    let mut s = String::from("zhangsan");
    println!("{s}");

    s.push('a');
    println!("{s}");

    // 编码为UTF-8,支持emoji
    s.push_str(":张三 😊😊");
    println!("{s}");

    // 字符串拼接
    let ss = s + "lisi";
    println!("{ss}");

    let c = String::from("kaka");
    // + 相当与add(),第二个参数为&str,所以第二个参数需为引用,同时&String会被强制转换为&str
    let combine = ss + &c;
    println!("{combine}");

    let a = "aaa";
    let b = "ccc";
    let ss = format!("{a}---{b}");
    println!("{ss}");

    let hello = String::from("hello");
    let s = &hello[0..3];
    println!("{s}");

    // 中文每个字符3个字节
    let hello = String::from("你好");
    let s = &hello[0..3];
    println!("{s}");

    // 遍历字符串的字符
    for c in hello.chars() {
        println!("{c}");
    }

    // 遍历字符串的字节
    for b in hello.bytes() {
        println!("{b}");
    }
}
